/*!
 * \file frexp2_comm.h
 *
 * \brief 关联连接共通管理
 *
 * All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.\n
 * 关联连接共通管理
 *
 * \version 2.0
 * \author yaohl
 * \date 2016/06/20
 *
 */

#ifndef __FREXP2_COMM_H_
#define __FREXP2_COMM_H_

#include <sys/time.h>
#include "frlist.h"

/*!
* @brief 关联链路分析用
*/
typedef struct __st_exp2
{
    char *p_id1;      /*!< id1 */
    char *p_id2;      /*!< id2 */

    Conntrack *p_st_ct;   /*!< ct */
    int refcnt;
    struct timeval st_timeval_upd;
} Frexp2;

/*!
 * 关联连接用哈希key
 *
 * \param p_id1     (id1)
 * \param p_id2     (id2)
 * \param p_key        (保存地址)
 * \param ui_key_size  (保存地址长度)
 *
 * \return key长度(出错是为0)
 *
 */
int frexpect2_hash_key(const char* p_id1
                     , const char* p_id2
                     , char *p_key
                     , unsigned int ui_key_size);

/*!
 * 增加关联连接
 *
 * \param p_frame_ref  (框架引用信息)
 * \param p_id1        (id1)
 * \param p_id2        (id2)
 * \param p_st_ct      (Conntrack *)
 *
 * \return FR_SUCC:成功\n
 *         FR_FAIL:失败
 */
int frexpect2_add(void* p_frame_ref
                , const char* p_id1
                , const char* p_id2
                , Conntrack *p_st_ct);

Conntrack *frexpect2_get(void* p_frame_ref, const char* p_id1, const char* p_id2);
int  frexpect2_put(void* p_frame_ref, const char* p_id1, const char* p_id2);


void expect2_node_free(Frlist_node* p_node);

/*!
 * 删除关联连接
 *
 * \param p_frame_ref  (框架引用信息)
 * \param p_id1        (id1)
 * \param p_id2        (id2)
 *
 * \return FR_SUCC:成功\n
 *         FR_FAIL:失败
 */
int frexpect2_del(void* p_frame_ref
                , const char* p_id1
                , const char* p_id2);

#endif
